package com.sky.mapper;

import com.sky.dto.ArticleCommentDTO;
import com.sky.dto.ArticleSubmitDTO;
import com.sky.dto.ArticleTopComments;
import com.sky.handler.JsonListTypeHandler;
import com.sky.vo.ArticleInfoVO;
import org.apache.ibatis.annotations.*;

import java.util.Collection;
import java.util.List;

/**
 * @author 贾晓晨
 * @version 1.0
 */
@Mapper
public interface ArticleMapper {
    @Select("select * from articles_info where article_id = #{id}")
    @Results({
            @Result(property = "articleId", column = "article_id"),
            @Result(property = "title", column = "title"),
            @Result(property = "titleImg", column = "title_img"),
            @Result(property = "content", column = "content"),
            @Result(property = "authorNickName", column = "author_nick_name"),
            @Result(
                    property = "tags",
                    column = "tags",
                    typeHandler = JsonListTypeHandler.class
            ),
            // 其他字段的映射
    })
    ArticleInfoVO getArticleDetail(String id);

    void sendFirstComment(ArticleCommentDTO articleCommentDTO);

    List<ArticleCommentDTO> selectCommentsByArticleUserId(String articleUserId);

    void saveArticle(ArticleSubmitDTO articleSubmitDTO);

}
